package pierwszy;

import org.openqa.selenium.NoSuchWindowException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class KsKModulesPage {
	private WebDriver driver;
	private WebDriverWait wait;
	private String modulesPageHeader =  "Lista modułów głównych";
	
	KsKModulesPage(WebDriver driver, WebDriverWait wait){
		this.driver = driver;
		this.wait = wait;
		
		if(!getModulesPageHeaderText().getText().equals(modulesPageHeader)){
			throw new NoSuchWindowException("This is not the KSKModulesPage page");
		}	
	}
	
	public void closeModulesPage(){
		wait.until(ExpectedConditions.presenceOfElementLocated(KsPModulesPageUiMapping.zamknijPageBtn));
		driver.findElement(KsPModulesPageUiMapping.zamknijPageBtn);
	}
	
	
	//getters
	public WebElement getModulesPageHeaderText(){
		wait.until(ExpectedConditions.presenceOfElementLocated(KsKModulesPageUiMapping.modulesPageHeader));
		
		return driver.findElement(KsKModulesPageUiMapping.modulesPageHeader);
	}
	
}
